package code.assets
{
	import code.interfaces.IContainerObject3D;
	
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	
	import org.papervision3d.core.proto.MaterialObject3D;
	import org.papervision3d.materials.BitmapMaterial;
	import org.papervision3d.objects.primitives.Plane;
	import org.papervision3d.scenes.Scene3D;
	
	public class LoadImagePlanes extends LoadImageCubes
	{
		public function LoadImagePlanes(topLevel:XML, scene:Scene3D, w:uint, d:uint)
		{
			super(topLevel, scene, w, d);
		}
		
		protected override function getContainerObject3D(topLevel:XML, img:DisplayObject):IContainerObject3D
		{
			var object3D:IContainerObject3D;
			var mMat:MaterialObject3D;
			var bd:BitmapData = new BitmapData(img.width, img.height);
			var h:uint = img.height;
			
			bd.draw(img);
			
			mMat = new BitmapMaterial(bd);
			mMat.interactive = true;
			mMat.smooth = true
			
			object3D = new ContainerPlane3D(mMat, img.width, img.height, 6, 6);
			(object3D as Plane).y = h/2;
			object3D.linkID = topLevel.a.@id;
			(object3D as Plane).name = topLevel.a.@id;
			
			return object3D;
		}
	}
}